home *** CD-ROM | disk | FTP | other *** search
- .MODEL MEMMOD,C
- LOCALS
- %MACS
- .LALL
-
- extrn Stktop,Spsave,Sssave,ecint:proc,doret:proc
-
- .CODE
- dbase dw @Data ; save loc for ds (must be in code segment)
-
- ; ec0vec - Ethernet interrupt handler
- public ec0vec
- label ec0vec far
- push ds ; save on user stack
- mov ds,cs:dbase ; establish interrupt data segment
-
- mov Sssave,ss ; stash user stack context
- mov Spsave,sp
-
- mov ss,cs:dbase
- lea sp,Stktop
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
-
- mov ax,0 ; arg for service routine
- push ax
- call ecint
- pop ax
- jmp doret
-
- ; ec1vec - Ethernet interrupt handler
- public ec1vec
- label ec1vec far
- push ds ; save on user stack
- mov ds,cs:dbase ; establish interrupt data segment
-
- mov Sssave,ss ; stash user stack context
- mov Spsave,sp
-
- mov ss,cs:dbase
- lea sp,Stktop
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
-
- mov ax,1 ; arg for service routine
- push ax
- call ecint
- pop ax
- jmp doret
-
- ; ec2vec - Ethernet interrupt handler
- public ec2vec
- label ec2vec far
- push ds ; save on user stack
- mov ds,cs:dbase ; establish interrupt data segment
-
- mov Sssave,ss ; stash user stack context
- mov Spsave,sp
-
- mov ss,cs:dbase
- lea sp,Stktop
-
- push ax ; save user regs on interrupt stack
- push bx
- push cx
- push dx
- push bp
- push si
- push di
- push es
-
- mov ax,2 ; arg for service routine
- push ax
- call ecint
- pop ax
- jmp doret
-
- ; fast buffer I/O routines -- used by 3-COM Ethernet controller
-
- ; outbuf - put a buffer to an output port
- public outbuf
- outbuf proc
- arg port:word,buf:ptr,cnt:word
- if @Datasize NE 0
- uses ds,si
- lds si,buf ; ds:si = buf
- else
- uses si
- mov si,buf ; ds:si = buf (ds already set)
- endif
-
- mov dx,port
- mov cx,cnt
- cld
-
- ; If buffer doesn't begin on a word boundary, send the first byte
- test si,1 ; (buf & 1) ?
- jz @@even ; no
- lodsb ; al = *si++;
- out dx,al ; out(dx,al);
- dec cx ; cx--;
- mov cnt,cx ; save for later test
- @@even:
- shr cx,1 ; cx = cnt >> 1; (convert to word count)
- ; Do the bulk of the buffer, a word at a time
- jcxz @@nobuf ; if(cx != 0){
- @@deloop:
- lodsw ; do { ax = *si++; (si is word pointer)
- out dx,al ; out(dx,lowbyte(ax));
- mov al,ah
- out dx,al ; out(dx,hibyte(ax));
- loop @@deloop ; } while(--cx != 0); }
- ; now check for odd trailing byte
- @@nobuf:
- mov cx,cnt
- test cx,1
- jz @@cnteven
- lodsb ; al = *si++;
- out dx,al
- @@cnteven:
- ret
- outbuf endp
-
- ; inbuf - get a buffer from an input port
- public inbuf
- inbuf proc
- arg port:word,buf:ptr,cnt:word
- uses di
- if @Datasize NE 0
- les di,buf ; es:di = buf
- else
- mov di,buf ; es:di = buf
- mov ax,ds
- mov es,ax
- endif
- mov dx,port
- mov cx,cnt
- cld
-
- ; If buffer doesn't begin on a word boundary, get the first byte
- test di,1 ; if(buf & 1){
- jz @@bufeven ;
- in al,dx ; al = in(dx);
- stosb ; *di++ = al
- dec cx ; cx--;
- mov cnt,cx ; cnt = cx; } save for later test
- @@bufeven:
- shr cx,1 ; cx = cnt >> 1; (convert to word count)
- ; Do the bulk of the buffer, a word at a time
- jcxz @@nobuf ; if(cx != 0){
- @@deloop:
- in al,dx ; do { al = in(dx);
- mov ah,al
- in al,dx ; ah = in(dx);
- xchg al,ah
- stosw ; *si++ = ax; (di is word pointer)
- loop @@deloop ; } while(--cx != 0);
- ; now check for odd trailing byte
- @@nobuf:
- mov cx,cnt
- test cx,1
- jz @@cnteven
- in al,dx
- stosb ; *di++ = al
- @@cnteven:
- ret
- inbuf endp
-
- end
-